package com.ytf.test.seventh;

/**
 * @author: YTF
 * @date: 2024/11/6 15:45
 * @version: 1.0
 * @description:
 */
public class Hide {
    public static void main(String[] args) {
        Bart bart = new Bart();
        bart.doh(1);
        bart.doh('x');
        bart.doh(1.0f);
        bart.doh(new MilHouse());

        /**
         * Output:
         * doh(float f)
         * doh(char c) 子类重写的
         * doh(float f)
         * doh(MilHouse milHouse)
         *
         * 注意:
         *  调用类中有方法用调用类的，没有才去父类查找。
         */
    }
}
class Homer{
    char doh(char c){
        System.out.println("doh(char c)");
        return 'd';
    }
    float doh(float f){
        System.out.println("doh(float f)");
        return 1.0f;
    }
}
class MilHouse{}
class Bart extends Homer{
    @Override
    char doh(char c) {
        System.out.println("doh(char c) 子类重写的");
        return 'e';
    }

    MilHouse doh(MilHouse milHouse) {
        System.out.println("doh(MilHouse milHouse)");
        return milHouse;
    }
}
